package com.andy.common.parser.impl;


import com.andy.common.parser.YamlFactory;
import com.andy.common.parser.YamlParse;
import com.andy.common.util.ExcelUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * Created by Administrator on 2017/9/4.
 */
public class ExcelFileParser extends YamlFactory {
    private static final Logger LOG = LoggerFactory.getLogger(ExcelFileParser.class);
    private YamlParse parser;
    private Class clazz;
    private Object obj;

    public ExcelFileParser(Class clazz, String filePath) {
        super(filePath);
        this.clazz = clazz;
    }

    protected Object parser() {
        if (parser == null) {
            parser = new YamlParse(clazz);
        }
        try {
            LOG.info("the file:{} is parsing ... ", path);
            obj = parser.parser(path);
            return obj;
        } catch (Exception e) {
            LOG.error("instance new class error {}", e);
        }
        return null;
    }

    public void init() {
        LOG.info("ExcelParser Factory init...");
    }

    public Object getObj() {
        return parser();
    }
}
